package cn.stylefeng.guns.modular.business.frequency.financedetail.mapper;

import cn.stylefeng.guns.modular.business.frequency.finance.model.param.FinanceDTO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.stylefeng.guns.modular.business.frequency.financedetail.entity.FinanceDetail;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 财务明细表 Mapper 接口
 *
 * @author yujie
 * @date 2023/05/09 17:17
 */
public interface FinanceDetailMapper extends BaseMapper<FinanceDetail> {

    void updateSettlementUserInfo(@Param("orderId") Long id, @Param("type") int i, @Param("settlementName") String linkmanName,@Param("settlementPhone") String linkmanPhone, @Param("settlementId") Long linkmanId);

    FinanceDetail getByOrderIdAndRelationId(@Param("type") Integer type,
                                            @Param("orderId") Long orderId,
                                            @Param("relationId") Long relationId);

    void deleteByOrderIdAndType(@Param("orderId") String orderId, @Param("type") Integer type);

    void deleteByOrderIdAndRelationId(@Param("relationId") Long relationId, @Param("orderId") Long orderId);

    @Delete("delete from tt_finance_detail where relation_id = #{id}")
    void deleteByRelationId(@Param("id") String id);


    FinanceDetail getByOrderIdAndType(@Param("orderId") Long orderId, @Param("type") Integer type);


    void deleteByOrderIdAndType(@Param("orderId") Long orderId, @Param("type") Integer type);


    List<FinanceDetail> getCheckFinanceDetail(@Param("financeDTO") FinanceDTO financeDTO,@Param("tenantId")Long tenantId);

    @Update("update tt_finance_detail set settlement_user = #{settlementName}, settlement_phone = #{settlementPhone}, " +
            "settlement_user_id #{settlementId} where relation_id = #{relationId}")
    void updateSettlementUserInfoByRelationId(
            @Param("relationId") Long relationId,
            @Param("settlementName") String settlementName,
            @Param("settlementPhone") String settlementPhone,
            @Param("settlementId") Long settlementId);
}